﻿#ifndef QWINMAINFORM_H
#define QWINMAINFORM_H

#include <QWidget>
#include <QStyleOption>
#include <QPainter>
#include <QDebug>
#include <QFile>
#include <QDesktopWidget>
#include <QPoint>


#include "QMainFormTitleBar.h"
#include "QPositionCalculator.h"

class QWinMainForm : public QWidget
{
    Q_OBJECT

public:
    explicit QWinMainForm(QWidget *parent = NULL);
    ~QWinMainForm();

signals:
    void MouseMoveMainForm(QPoint Position);

public slots:
    void resizeEvent(QResizeEvent *event);
    void paintEvent(QPaintEvent* paintEvent);
    virtual void mouseDoubleClickEvent(QMouseEvent* event);
    virtual void mouseMoveEvent(QMouseEvent *event);
    virtual void mousePressEvent(QMouseEvent *event);
    virtual void mouseReleaseEvent(QMouseEvent *event);
    virtual void leaveEvent();
    virtual void hoverMoveEvent(QMouseEvent *event);
    virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result);
    virtual bool eventFilter(QObject *obj, QEvent *event);
    virtual void showMaximizedMinimized();
    virtual void moveMainForm(QPoint Position);

protected:
    QMainFormTitleBar* MainFormTitleBar;
    QPositionCalculator* PositionCalculator;

    void WindowsCentering() {
        QDesktopWidget DesktopWidget;
        int deskWidth = DesktopWidget.availableGeometry().width();
        int deskHeight = DesktopWidget.availableGeometry().height();
        QPoint movePoint(deskWidth / 2 - width() / 2, deskHeight / 2 - height() / 2);
        move(movePoint);
    }

protected:
    QFile* StyleSheetFile;
    bool IsTitleMousePress;
    QPoint MousePosition;
    QSize FormNormalSize;
};

#endif // QWINMAINFORM_H
